package com.xqb.modules.controller.exam;

import com.xqb.common.annotation.Log;
import com.xqb.common.core.controller.BaseController;
import com.xqb.common.core.domain.AjaxResult;
import com.xqb.common.core.page.TableDataInfo;
import com.xqb.common.enums.BusinessType;
import com.xqb.common.utils.poi.ExcelUtil;
import com.xqb.modules.domain.po.ExaQuestionBiz;
import com.xqb.modules.service.IExaQuestionBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 问题和业务关联Controller
 * 
 * @author xqb
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/exam/question_biz")
public class ExaQuestionBizController extends BaseController
{
    @Autowired
    private IExaQuestionBizService exaQuestionBizService;

    /**
     * 查询问题和业务关联列表
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExaQuestionBiz exaQuestionBiz)
    {
        startPage();
        List<ExaQuestionBiz> list = exaQuestionBizService.selectExaQuestionBizList(exaQuestionBiz);
        return getDataTable(list);
    }

    /**
     * 导出问题和业务关联列表
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:export')")
    @Log(title = "问题和业务关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExaQuestionBiz exaQuestionBiz)
    {
        List<ExaQuestionBiz> list = exaQuestionBizService.selectExaQuestionBizList(exaQuestionBiz);
        ExcelUtil<ExaQuestionBiz> util = new ExcelUtil<ExaQuestionBiz>(ExaQuestionBiz.class);
        util.exportExcel(response, list, "问题和业务关联数据");
    }

    /**
     * 获取问题和业务关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(exaQuestionBizService.selectExaQuestionBizById(id));
    }

    /**
     * 新增问题和业务关联
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:add')")
    @Log(title = "问题和业务关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExaQuestionBiz exaQuestionBiz)
    {
        return toAjax(exaQuestionBizService.insertExaQuestionBiz(exaQuestionBiz));
    }

    /**
     * 修改问题和业务关联
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:edit')")
    @Log(title = "问题和业务关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExaQuestionBiz exaQuestionBiz)
    {
        return toAjax(exaQuestionBizService.updateExaQuestionBiz(exaQuestionBiz));
    }

    /**
     * 删除问题和业务关联
     */
    @PreAuthorize("@ss.hasPermi('exam:question_biz:remove')")
    @Log(title = "问题和业务关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(exaQuestionBizService.deleteExaQuestionBizByIds(ids));
    }
}
